//
//  HomeRankViewController.m
//  sklive
//
//  Created by Macx on 2017/6/28.
//  Copyright © 2017年 Macx. All rights reserved.
//

#import "HomeRankViewController.h"
#import "YHJTabPageScrollView.h"

#import "RankTableViewCell.h"

#import "RankView.h"

#import <Masonry.h>

@interface HomeRankViewController () <UITableViewDelegate, UITableViewDataSource>

@property (nonatomic,strong) YHJTabPageScrollView *pageScroll;


@end

@implementation HomeRankViewController {
    
    RankTableViewCell   *_cell;
    UITableView         *_tableView;
    UIView              *_praiseView;
}

- (void)viewWillAppear:(BOOL)animated {
    [self.navigationController setNavigationBarHidden:YES animated:animated];
}
- (void)viewWillDisappear:(BOOL)animated {
    [self.navigationController setNavigationBarHidden:NO animated:animated];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    [self buildUI];
    
}


#pragma mark ==========构建UI==========
- (void)buildUI {
    
    self.view.backgroundColor = [UIColor whiteColor];
    
    UIView *navBgView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 64)];
    [self.view addSubview:navBgView];
    navBgView.backgroundColor = UIMainColorRGB;
    
    UIView *view1 = [UIView new];
    view1.backgroundColor = kGreenColor;
    
    UIView *view2 = [[RankView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT-64) type:1];
    
    UIView *view3 = [[RankView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT-64) type:2];
    
    UIView *view4 = [[RankView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT-64) type:3];
    
    NSArray *pageItems = @[
                           [[YHJTabPageScrollViewPageItem alloc]initWithTabName:@"点赞" andTabView:view1],
                           [[YHJTabPageScrollViewPageItem alloc]initWithTabName:@"送礼" andTabView:view2],
                           [[YHJTabPageScrollViewPageItem alloc]initWithTabName:@"收礼" andTabView:view3],
                           [[YHJTabPageScrollViewPageItem alloc]initWithTabName:@"粉丝" andTabView:view4]
                           ];
    _pageScroll = [[YHJTabPageScrollView alloc]initWithPageItems:pageItems];
    
    [self.view addSubview:_pageScroll];
    
    [_pageScroll mas_makeConstraints:^(MASConstraintMaker *make){
        make.top.equalTo(self.view.mas_top).offset(20);
        make.left.equalTo(self.view.mas_left);
        make.right.equalTo(self.view.mas_right);
        make.bottom.equalTo(self.view.mas_bottom);
    }];
    
    // 左上角返回
    UIButton *returnBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.view addSubview:returnBtn];
    [returnBtn setImage:[UIImage imageNamed:@"return"] forState:UIControlStateNormal];
    returnBtn.frame = CGRectMake(0, 20, SW(10), 40);
    [returnBtn addTarget:self action:@selector(returnAction:) forControlEvents:UIControlEventTouchUpInside];
    
}

#pragma mark ==========响应方法==========
- (void)returnAction:(UIButton *)sender {
    [self.navigationController popViewControllerAnimated:YES];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
